

FILE=led
NODE=arduino_puzzle

$(FILE)_$(NODE)_loop:
	mkdir $(FILE)_$(NODE)_loop

v6: led.lus $(FILE)_$(NODE)_loop
	lv6 -2c $(FILE).lus -n $(NODE)
	mv *.h $(FILE)_$(NODE)_loop/
	mv $(FILE)_$(NODE).c $(FILE)_$(NODE)_loop/$(FILE)_$(NODE).cpp

%.simu:
	cp lustre/arduino_$*.lus arduino_puzzle.lus
	luciole-rif lv6 -exec -rif led.lus -n $* &

%.arduino:
	cp lustre/arduino_$*.lus arduino_puzzle.lus
	make v6

%.no_sol:
	cp lustre/arduino_$*.lus arduino_puzzle.lus
	lv6 -ec -o no_sol.ec led.lus -n $*_has_no_solution
	ecverif no_sol.ec -diag > $*.diag ; echo >> $*.diag || echo "$*: il existe une solution ! La voici:" \
       echo "$*: ce puzzle est insoluble"
	cat $*.diag | sed 's/true//'  | sed 's/not\ red//' |  sed 's/not\ red\ or//'  |  sed 's/not\ blue\ or//'  |  sed 's/not\ blue//' | sed 's/\ and\ //'  


%.test:
	cp lustre/arduino_$*.lus arduino_puzzle.lus
	rdbg -lurette -l 1000  -sut "lv6 led.lus -n $*" -env "lutin env.lut -n random_env" -oracle "lv6 led.lus -n $*_has_no_solution" -o $*.rif || echo "Ce puzzle a une solution !"
	gnuplot-rif $*.rif -no-display
	gnuplot  -e 'set terminal qt size 1800,400' $*.gp

%.debug:
	rdbg -emacs -sut "lv6 led.lus -n $*"


clean:
	rm -f *.c *.h *.ec *.sh *.rif *ession*.ml *.gp *.log *.dro *.seed *.diag
	rm -f *.ps *.pdf *.dot *.cm* *.o  arduino_puzzle.lus
	rm -f led_arduino_puzzle_loop/led_arduino_puzzle.cpp
	rm -f led_arduino_puzzle_loop/*.h
	rm -f my-rdbg-tuning.ml

a1: puzzle1.arduino
s1: puzzle1.simu
p1: puzzle1.no_sol
t1: puzzle1.test

a2: puzzle2.arduino
s2: puzzle2.simu
p2: puzzle2.no_sol
t2: puzzle2.test

a3: puzzle3.arduino
s3: puzzle3.simu
p3: puzzle3.no_sol
t3: puzzle3.test

a4: puzzle4.arduino
s4: puzzle4.simu
p4: puzzle4.no_sol
t4: puzzle4.test

a5: puzzle5.arduino
s5: puzzle5.simu
p5: puzzle5.no_sol
t5: puzzle5.test

a6: puzzle6.arduino
s6: puzzle6.simu
p6: puzzle6.no_sol
t6: puzzle6.test


TARGET=led
USR_SRCS= \
	./objs/mycode_puzzle.cpp \
	led_arduino_puzzle_loop.cpp \



# Thinks that can be  customized
USR_CPP_FLAGS=
USR_CC_FLAGS=
USR_INCLS=-I./objs

./objs/mycode_puzzle.cpp: led.lus
	cd ./objs; lv6 ../led.lus -n arduino_puzzle -2c; mv arduino_puzzle_arduino_puzzle.c arduino_puzzle_arduino_puzzle.cpp

# include ArduinoMega.mk
